package com.wt.struggle.goodbye.view

import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.LinearLayout
import android.widget.PopupWindow
import com.wt.struggle.goodbye.R
import kotlinx.android.synthetic.main.add_comment_pop.view.*

class AddCommentPop(context: Context) : PopupWindow() {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.add_comment_pop, null)
        contentView = view
        width = LinearLayout.LayoutParams.MATCH_PARENT
        height = LinearLayout.LayoutParams.WRAP_CONTENT
        setBackgroundDrawable(BitmapDrawable())
        isOutsideTouchable = true
        isFocusable = true
        animationStyle = R.style.pop_anima

    }

    fun show(callBack: OnAddBackListener) {
        val content = contentView.etAddComment.text.toString()
        contentView.buttonSend.setOnClickListener {
            if (callBack != null) {
                callBack.onBack(content)
            }
        }

        showAtLocation(contentView, Gravity.BOTTOM, 0, 0)
    }


    interface OnAddBackListener {
        fun onBack(content: String)
    }
}